Skip to content

Conversation

@NikolayS
Copy link
Contributor

@NikolayS NikolayS commented Dec 22, 2025

Summary

  • When creating a clone without specifying a branch or snapshot, default to "main" branch
  • When a specific snapshot is requested but no branch specified, use the snapshot's branch (maintains consistency)
  • UI: Prioritize "main" branch in the branch selector dropdown

Changes

API (engine/internal/cloning/base.go):

  • Default to "main" only when neither branch nor snapshot are specified
  • Use snapshot's branch when snapshot is specified but branch is not

UI (ui/packages/shared/pages/CreateClone/index.tsx):

  • Default branch selector to "main" if available, fallback to first branch

Tests (engine/internal/cloning/base_test.go):

  • Added TestDefaultBranchForCloneCreation covering all branch selection scenarios

Behavior

Branch Specified Snapshot Specified Result
No No Default to "main"
No Yes Use snapshot's branch
Yes Any Use specified branch

Fixes: https://gitlab.com/postgres-ai/database-lab/-/issues/662

When creating a clone without specifying a branch, both the UI and API
now default to "main" branch instead of using the first available
branch or the snapshot's branch.

UI: Changed to prioritize "main" branch when selecting default.
API: Changed default from snapshot.Branch to branching.DefaultBranch.

Related: https://gitlab.com/postgres-ai/database-lab/-/issues/662
Adds TestDefaultBranch to ensure the DefaultBranch constant
remains set to "main" and doesn't regress.
Adds TestDefaultBranchForCloneCreation with multiple test cases:
- Empty branch defaults to main (regardless of snapshot branch)
- Explicit branch names are preserved

Removes simple constant test in favor of behavior test.
When a specific snapshot is requested but no branch is specified,
use the snapshot's branch to maintain consistency. Only default
to "main" when neither branch nor snapshot are specified.

- No branch + no snapshot → default to main
- No branch + snapshot specified → use snapshot's branch
- Explicit branch → use specified branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants